# Maintainer: Giancarlo Razzolini <grazzolini@archlinux.org>
pkgname=dracut
pkgver=059
pkgrel=4
pkgdesc="An event driven initramfs infrastructure"
arch=('loong64' 'x86_64')
url="https://github.com/dracutdevs/dracut"
license=('GPL')
depends=('bash' 'coreutils' 'cpio' 'filesystem' 'findutils' 'grep' 'gzip'
         'kmod' 'pkgconf' 'procps-ng' 'sed' 'systemd' 'util-linux' 'xz')
makedepends=('asciidoc' 'bash-completion' 'git')
optdepends=('binutils: --uefi option support'
            'elfutils: strip binaries to reduce initramfs size'
            'multipath-tools: dmraid dracut module support'
            'pigz: faster gzip compression'
            'sbsigntools: uefi_secureboot_cert/key configuration option support')
provides=('initramfs')
backup=('etc/dracut.conf')
source=("${pkgname}-${pkgver}::git+${url}#tag=${pkgver}?signed"
        dracut-systemd-253.patch
        dracut-systemd-254-uki.patch::https://github.com/dracutdevs/dracut/commit/f32e95bcadbc5158843530407adc1e7b700561b1.patch
        dracut-systemd-255-systemd-executor.patch::https://github.com/dracutdevs/dracut/pull/2535/commits/62fd8ebe4776dbb60ca04a865c2d160e45d65e91.patch)
sha512sums=('SKIP'
            'dfbef5ee06fd0f7b51bfd3571eb284272d7694754eaf232cf1a14f3b2f95a67c87098fabf6d88068ef7e235e717bec26024a3b342c5dba940b8600799cef0791'
            '8d232afccf84e24348c0e13d8eb34bcf670ca98a8e6a1e17cd4e861b8c036db1431ad8d8cb3942fb7645489d450dc2dbb91d54c18275796be26aae3ec53db557'
            '9940448b4a83c9a837a916557b413b4523097554175420e554e039baa0395a387634bdf4486c212b930942a32e4f336b65e3d6624517b3e134b010a614fbcb41')
b2sums=('SKIP'
        '6386d1caf4765974e6f9fffde43cacc20f55a1ed487f6dba9f6f15318dc6dc593ef01309679c8a7f1deffc5dd66138cde7c11d53a825396971d6be29a9388744'
        '8adf7975e1edc37a9c4972243324a0ecc6f1eebc012a59dcc9a394e2f2f669650200fff4d87088dffd133b1531c7eaac390322ba9b18f826a804d61b6341908b'
        '4ef34f747a0f0e446ae9429559ddfe5d3d2088b1071433bba131aed0fb553d44a6256016f8fccd891c3dd69f554af3fe98ac1dcebd62a0489864e75b4b413f48')
validpgpkeys=('F66745589DE755B02AD947D71F1139EBBED1ACA9') # Jóhann B. Guðmundsson <johannbg@gmail.com>

prepare() {
  cd "$srcdir/${pkgname}-${pkgver}"

  patch -Np1 < ../dracut-systemd-253.patch
  patch -Np1 < ../dracut-systemd-254-uki.patch
  patch -Np1 < ../dracut-systemd-255-systemd-executor.patch
}

build() {
  local prefix=/usr sysconfdir=/etc

  cd "$srcdir/${pkgname}-${pkgver}"

  ./configure \
    --sysconfdir=${sysconfdir} \
    --prefix=${prefix} \
    --libdir=${prefix}/lib \
    --systemdsystemunitdir=${prefix}/lib/systemd/system \
    --bashcompletiondir=$(pkg-config --variable=completionsdir bash-completion)
  make
}

package() {
  cd "$srcdir/${pkgname}-${pkgver}"

  DESTDIR="$pkgdir" make install
}
